const children = [

];
const routes = [

    //访问路由“/”,自动重定向到"/home"
    /*
        home/路由下是面向用户的页面
        m_home/路由下是面向管理员的页面
    */
    {
        path: '/',
        redirect: '/home'
    },
    {
        path: '/login',
        name: 'Login',
        component: () =>
            import ('@/views/login.vue')
    },
    {
        path: '/m_login',
        name: 'MLogin',
        component: () =>
            import ('@/views/m_login.vue')
    },
    {
        path: '/register',
        name: 'Register',
        component: () =>
            import ('@/views/register.vue')
    },
    {
        path: '/home',
        name: 'Home',
        component: () =>
            import ('@/views/home/home.vue'),
        children: [{
                path: '/home/index',
                name: 'Index',
                component: () =>
                    import ('@/views/home/index.vue')
            },
            {
                path: '/home/cust_movie',
                name: 'Movie',
                component: () =>
                    import ('@/views/home/movie.vue')
            },
            {
                path: '/home/cust_cinema',
                name: 'Cinema',
                component: () =>
                    import ('@/views/home/cinema.vue')
            },
            {
                path: '/home/cust_info',
                name: 'Cust_info',
                component: () =>
                    import ('@/views/home/cust_info.vue')
            },
            {
                path: '/home/cust_ticket',
                name: 'Cust_ticket',
                component: () =>
                    import ('@/views/home/ticket.vue')
            },
            {
                path: '/home/cust_order',
                name: 'Cust_order',
                component: () =>
                    import ('@/views/home/order.vue')
            },
            {
                path: '/home/cust_feedback',
                name: 'Cust_feedback',
                component: () =>
                    import ('@/views/home/feedback.vue')
            },
            {
                path: '/home/movie_detail',
                name: 'Movie_detail',
                component: () =>
                    import ('@/views/home/movie_detail.vue')
            },
            {
                path: '/home/seat',
                name: 'Seat',
                component: () =>
                    import ('@/views/home/seat.vue')
            },
            {
                path: '/home/cinema',
                name: 'Cinema_info',
                component: () =>
                    import ('@/views/home/cinemaInfo.vue')
            },
        ]
    },

    {
        path: '/m_home',
        name: 'M_home',
        component: () =>
            import ('@/views/m_home/m_home.vue'),
        children: [{
                path: '/security/user',
                name: 'security_user',
                component: () =>
                    import ('@/views/security/user/user.vue')
            },
            {
                path: '/security/admin',
                name: 'security_admin',
                component: () =>
                    import ('@/views/security/admin/admin.vue')
            },
            {
                path: '/security/c_admin',
                name: 'security_c_admin',
                component: () =>
                    import ('@/views/security/c_admin/c_admin.vue')
            },
            {
                path: '/admin/index',
                name: 'admin_index',
                component: () =>
                    import ('@/views/admin/index/index.vue')
            },
            {
                path: '/admin/cinema',
                name: 'admin_cinema',
                component: () =>
                    import ('@/views/admin/cinema/cinema.vue')
            },
            {
                path: '/admin/feedback',
                name: 'admin_feedback',
                component: () =>
                    import ('@/views/admin/feedback/feedback.vue')
            },
            {
                path: '/admin/comment',
                name: 'admin_comment',
                component: () =>
                    import ('@/views/admin/comment/comment.vue')
            },
            {
                path: '/admin/info',
                name: 'admin_info',
                component: () =>
                    import ('@/views/admin/info/info.vue')
            },
            {
                path: '/admin/movie',
                name: 'admin_movie',
                component: () =>
                    import ('@/views/admin/movie/movie.vue')
            },
            {
                path: '/search/profit',
                name: 'admin_profit',
                component: () =>
                    import ('@/views/search/profit/profit.vue')
            },


            {
                path: '/c_admin/index',
                name: 'c_admin_index',
                component: () =>
                    import ('@/views/c_admin/index/index.vue')
            },
            {
                path: '/c_admin/movie',
                name: 'c_admin_movie',
                component: () =>
                    import ('@/views/c_admin/movie/movie.vue')
            },
            {
                path: '/c_admin/feedback',
                name: 'c_admin_feeedback',
                component: () =>
                    import ('@/views/c_admin/feedback/feedback.vue')
            },
            {
                path: '/c_admin/hall',
                name: 'c_admin_hall',
                component: () =>
                    import ('@/views/c_admin/hall/hall.vue')
            },
            {
                path: '/c_admin/info',
                name: 'c_admin_info',
                component: () =>
                    import ('@/views/c_admin/info/info.vue')
            },
            {
                path: '/search/c_profit',
                name: 'c_admin_profit',
                component: () =>
                    import ('@/views/search/c_profit/profit.vue')
            },
        ]
    },
    {
        path: '/404',
        name: "NotFound",
        component: () =>
            import ('@/views/404.vue')
    }

];

export const existsRoute = (path) => {
    for (let i = 0; i < routes.length; i++) {
        const r = routes[i];
        if (r.path == path) {
            return true;
        }
        if (r.children && r.children.length) {
            for (let k = 0; k < r.children.length; k++) {
                const sr = r.children[k];
                if (sr.path == path) {
                    return true;
                }
            }
        }
    }
    return false;
};

export default routes;